from time import sleep
import uiautomation
import pyautogui
class zhuyuanyaofangfayao():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()

        #状态
        zhuangtai = his.ComboBoxControl(AutomationId='cmbState', ClassName='ComboBox')
        weifayao = zhuangtai.ListItemControl(Name='[未发药, 0]')
        yifayao = zhuangtai.ListItemControl(Name='[已发药, 2]')

        #药房
        yaofang1 = his.ComboBoxControl(AutomationId='cmbYF', ClassName='ComboBox')
        yaofang2 = yaofang1.ListItemControl(Name='药房(4007)')
        cailiaofang = yaofang1.ListItemControl(Name='材料房(333336)')

        #病区
        bingqu = his.ComboBoxControl(ClassName='ComboBox',foundIndex=3)
        quanbu = bingqu.ListItemControl(Name='全部()')

        huanzhexinxishurukuang = his.EditControl(ClassName='TextBox',foundIndex=5)
        chaxun = his.ButtonControl(AutomationId='search_btn', ClassName='Button',Name='查询')
        fayao = his.ButtonControl(AutomationId='btnPutDrug', ClassName='Button',Name='发药')
        huanzhexuanxiangka = his.TabItemControl(AutomationId='tabHZ', ClassName='TabItem',Name='患者')
        shuju1= huanzhexuanxiangka.DataGridControl(AutomationId='dgHZList').DataItemControl(ClassName='DataGridRow',SubName='ViewModel.ZyYf.YFHZ').CustomControl(ClassName='DataGridCell',SubName='列显示索引: 0')

        #系统提示窗口
        xitongtishichuangkou = his.WindowControl(Name='系统提示')
        queding = xitongtishichuangkou.ButtonControl(AutomationId='YesBtn', ClassName='Button',Name='是')
        quxiao = xitongtishichuangkou.ButtonControl(AutomationId='NoBtn', ClassName='Button',Name='否')

        #选择未发药
        def choose_wfy(self):
                self.zhuangtai.Click()
                self.weifayao.Click()
        #选择已发药
        def choose_yfy(self):
                self.zhuangtai.Click()
                self.yifayao.Click()

        #选择药房
        def choose_yf(self):
                self.yaofang1.Click()
                self.yaofang2.Click()
        #选择材料房
        def choose_clf(self):
                self.yaofang1.Click()
                self.cailiaofang.Click()

        #选择病区
        def choose_bq(self):
                self.bingqu.Click()
                self.quanbu.Click()
        #输入住院患者姓名
        def input_name(self,name):
                self.huanzhexinxishurukuang.Click()
                pyautogui.hotkey('ctrl', 'a')
                pyautogui.hotkey('back')
                self.huanzhexinxishurukuang.SendKeys(name)
        #点击查询按钮
        def click_cx_btn(self):
                self.chaxun.Click()
        #点击患者选项卡
        def click_hz(self):
                self.huanzhexuanxiangka.Click()
                self.shuju1.Click()


        #点击发药
        def clicl_fy_btn(self):
                self.fayao.Click()

        #点击提示确定按钮
        def click_tsqd_btn(self):
                self.xitongtishichuangkou.Refind()
                self.queding.Refind()
                self.queding.Click()
        #点击提示取消按钮
        def click_tsqx_btn(self):
                self.xitongtishichuangkou.Refind()
                self.quxiao.Refind()
                self.quxiao.Click()


















